package demo;

import java.util.LinkedList;
import java.util.Stack;

public class MyQueue {

    private Stack<Integer> stack1;
    private Stack<Integer> stack2;


    public MyQueue() {
        stack1 = new Stack<>();
        stack2 = new Stack<>();
    }

    public void push(int x) {
        stack1.push(x);
    }

    public int pop() {
        if (stack1.isEmpty()){
            return -1;
        }
        int size = stack1.size();
        for(int i =0;i<size;i++){
            int tmp = stack1.pop();
            stack2.push(tmp);
        }
        int tmp = stack2.pop();

        size = stack2.size();
        for(int i =0;i<size;i++){
            int tmp2 = stack2.pop();
            stack1.push(tmp2);
        }

        return tmp;

    }

    public int peek() {
        int size = stack1.size();
        for(int i =0;i<size;i++){
            int tmp = stack1.pop();
            stack2.push(tmp);
        }
        int tmp = stack2.peek();

        size = stack2.size();
        for(int i =0;i<size;i++){
            int tmp2 = stack2.pop();
            stack1.push(tmp2);
        }


        return tmp;
    }

    public boolean empty() {
        if (stack1.isEmpty()){
            return true;
        }
        return false;

    }


}
